#!/bin/bash
#
# Setup windows box
#
. scripts/functions

echo "Trying to setup $WIN32_ADDR"
URL=http://$WIN32_ADDR:8091

echo "Stopping susan-fd service"
wget -qO /dev/null "$URL/stop"

echo -en "Set director name:\t\t"
wget -qO - "$URL/set_director_name?name=$HOST-dir;pass=$WIN32_PASSWORD"

if [ x$WIN32_USER != x ]; then
    echo -en "Setting auto_logon:\t\t"
    wget -qO - "$URL/set_auto_logon?user=$WIN32_USER;pass=$WIN32_PASS"
fi

update_win32

echo "Starting susan-fd service"
wget -qO /dev/null "$URL/start"

echo -ne "Reloading regress-win32.pl:\t"
wget -qO - "$URL/reload"

i=0
while ! wget -qO /dev/null $URL/nop; do
    sleep 5
    i=`expr $i + 1`
    if [ $i -ge 12 ]; then  # print message every minute
       i=0
       echo "== `date +%T` Waiting for script to reload"
    fi
done
